package org.crystalrange.documents.web;

import java.util.ArrayList;
import java.util.List;

import org.crystalrange.documents.model.Document;
import org.crystalrange.documents.model.DocumentLockedHistory;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;

public class DocumentLockedHistoryList extends GenericForwardComposer {
	
	private Document document;
	protected List<DocumentLockedHistory> documentLockedHistorys;
	
	public Document getDocument() {
		return document;
	}

	public List<DocumentLockedHistory> getDocumentLockedHistorys() {
		return documentLockedHistorys;
	}

	@Override
	public void doAfterCompose(Component component) throws Exception {
		super.doAfterCompose(component);
		this.document = (Document) this.execution.getAttribute("document");
		this.documentLockedHistorys = new ArrayList<DocumentLockedHistory>();
		this.documentLockedHistorys = this.document.getDocumentLockedHistorys();
		component.setAttribute("controller", this);
	}
	
	public void onClick$buttonOk(Event event) throws Exception {
		this.self.detach();
	}
}
